#!/usr/bin/ruby
$:.unshift File.join(File.dirname(__FILE__))
require 'AWS/EC2'
require 'basic_configuration'
require 'aws_context'
require 'pp'

# Creates a security group.
# At first, it has no security rules in it.

if ARGV[0] == '-?' || ARGV.size != 2 then
  puts "usage: create-group name description"
  exit 1
end
name=ARGV[0]
description=ARGV[1]

Signal.trap("INT") do
  exit 2
end

config = BasicConfiguration.new
ec2 = AwsContext.instance.ec2(*config.keys)
begin
  ec2.create_security_group(name, description)
  puts "created group"
rescue
  puts "error #{$!} #{name}"
  exit 1
end

